import request from '@/utils/request'

// 从配置中获取业务的地址
import { baseUrlConfig } from '@/config/config'
const basePath = baseUrlConfig.businessBaseUrl

interface Order{
  column:string;
  method:string;
}
export interface PageListType {
  type?: any;
  pageNum?: number;
  pageSize?: number;
  eqptCode?: string;
  regionList?: [];
  terminalList?: [];
  order?: Array<Order>;
}

export const chargePageList: (data: PageListType) => Promise<[]> = (data: PageListType) => {
  return request({
    url: basePath + '/charging/find/page',
    method: 'post',
    data: {
      pageNum: data.pageNum,
      pageSize: data.pageSize,
      condition: {
        eqptCode: data.eqptCode,
        terminalList: data.terminalList,
        regionList: data.regionList,
        order: data.order
      }
    }
  })
}

// 删除
export const chargeDelete = (data: any) => {  
  return request({
    url: basePath + `/charging/delete?eqptId=${data}`,
    method: 'post',
  
  })
}

// 模板下载
export const listDownload = () => {
  return request({
    url: basePath + '/charging/exports',
    method: 'post',
    data: {},
    responseType: 'blob'
  })
}

// 导入列表
export const listImport = (data: any) => {
  return request({
    url: basePath + '/charging/import',
    method: 'post',
    data
  })
}

// 导出列表
export const listExport: (data: PageListType) => Promise<[]> = (data: PageListType) => {
  return request({
    url: basePath + '/charging/export',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

// 新增
export const chargeAdd = (data: any) => {
  return request({
    url: basePath + '/charging/append',
    method: 'post',
    data
  })
}

// 修改
export const chargeUpdate = (data: any) => {
  return request({
    url: basePath + '/charging/update',
    method: 'post',
    data
  })
}

// 获取设备类型
export const geteqptType = (data: any) => {
  return request({
    url: basePath + '/eqpt/type/find',
    method: 'post',
    data
  })
}
